{% extends 'root.html' %}

{% block root_content %}
    {% if deleted_picture %}
    <div class="deleted">
        <h3>Deleted picture {{deleted_picture.name}}</h3>
    </div>
    {% endif %}
    <table>
        <tr>
    {% for picture in pictures %}
            <td>
                <div class="picture">
                    <ul>
                    <li><a href="{% url show_picture picture.id %}"><img alt={{picture.description}} src="{{picture.uri}}" /></a></li>
                    <li><a href="{% url delete_picture picture.id %}" onclick="return askConfirmation()">Delete</a></li>
                    </ul>
                </div>
            </td>
        {% if forloop.counter|divisibleby:6 and not forloop.last%}
        </tr><tr>
        {% endif %}
    {% empty %}
        <td>You have no pictures, <a href="{% url upload_new_picture %}">upload a new one</a> 
            or <a href="{% url add_new_picture %}">add one by url</a>.</td>
    {% endfor %}
        </tr>
    </table>

<script type="text/javascript">
    function askConfirmation() {
        return confirm("Are you sure you want to delete picture?");
    }
</script>
{% endblock %}
